﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using BusinessModel;
using EntityDataModel;
using System.ComponentModel;
using System.Data.Objects.DataClasses;

namespace Controller.DataProvider
{
    public class DiscountTypePro : GenericProvider<DiscountType>
    {
        public DiscountTypePro()
        {
            EntityName = "Tbl_DiscountType";
        }

        #region override Methods
        //----------------------------------------
        public override EntityObject CreateEntity()
        {
            return new Tbl_DiscountType();
        }
        //----------------------------------------
        public override DiscountType CreateModel()
        {
            return new DiscountType();
        }
        //----------------------------------------
        public override void ToEntity(DiscountType pModel, EntityObject pEntity, params EnumFieldCopy[] pEnumFieldCopys)
        {
            Tbl_DiscountType oEntity = pEntity as Tbl_DiscountType;
            oEntity.Name = pModel.Name;
            pEnumFieldCopys.ToList().ForEach((item) =>
            {
                switch (item)
                {
                    case EnumFieldCopy.Id:
                        oEntity.Id = pModel.Id;
                        break;
                    case EnumFieldCopy.Created:
                        oEntity.CreatedBy = pModel.CreatedBy;
                        oEntity.CreatedDate = pModel.CreatedDate;
                        break;
                    case EnumFieldCopy.Modified:
                        oEntity.ModifiedBy = pModel.ModifiedBy;
                        oEntity.ModifiedDate = pModel.ModifiedDate;
                        break;
                    case EnumFieldCopy.All:
                        oEntity.Id = pModel.Id;
                        oEntity.CreatedBy = pModel.CreatedBy;
                        oEntity.CreatedDate = pModel.CreatedDate;
                        oEntity.ModifiedBy = pModel.ModifiedBy;
                        oEntity.ModifiedDate = pModel.ModifiedDate;
                        break;
                }
            });
        }
        //----------------------------------------
        public override void ToModel(EntityObject pEntity, DiscountType pModel, params EnumFieldCopy[] pEnumFieldCopys)
        {
            Tbl_DiscountType oEntity = pEntity as Tbl_DiscountType;
            pModel.Name = oEntity.Name;
            pEnumFieldCopys.ToList().ForEach((item) =>
            {
                switch (item)
                {
                    case EnumFieldCopy.Id:
                        pModel.Id = oEntity.Id;
                        break;
                    case EnumFieldCopy.Created:
                        pModel.CreatedBy = oEntity.CreatedBy;
                        pModel.CreatedDate = oEntity.CreatedDate;
                        break;
                    case EnumFieldCopy.Modified:
                        pModel.ModifiedBy = oEntity.ModifiedBy;
                        pModel.ModifiedDate = oEntity.ModifiedDate;
                        break;
                    case EnumFieldCopy.All:
                        pModel.Id = oEntity.Id;
                        pModel.CreatedBy = oEntity.CreatedBy;
                        pModel.CreatedDate = oEntity.CreatedDate;
                        pModel.ModifiedBy = oEntity.ModifiedBy;
                        pModel.ModifiedDate = oEntity.ModifiedDate;
                        break;
                }
            });
        }
        #endregion override Methods
    }
}
